
#pragma once
#include "SSCalculator.h"
#include "YieldCurveModule/RateBondAnalysis.h"
#include "YieldCurveModule/utility.h"
using namespace YieldCurve;

// Get remaining years from start and end dates, format=yyyymmdd
double SSCALCULATOR_API AfxGetRemainingMaturity(int startDate, int endDate);

// Use previous day's quote as today's.
void SSCALCULATOR_API AfxFillMissingData(std::vector<double>& yields);

class SSCALCULATOR_API CSSYieldCurve {
 public:
  CSSYieldCurve();
  ~CSSYieldCurve();

 public:
  // Return a yield curve pointer per given bond data and yield curve type
  // The caller needs to delete the pointer!
  BondYieldCurve* GetParCurve(
      const std::vector<YCInfo>& bondData,
      const int yieldDate,              // Input: Date the curve represents.
                                        // format:yyyymmdd, ie:20130507
      YieldCurveType ycType = GOV_BOND  // Input: Curve type
  );

  // Return a vector of interpolated yield curve points from give quotes
  // static std::vector<YCPoint> GetYieldCurvePoints(const std::vector<YCInfo>&
  // bondData, const int yieldDate, std::vector<double> samplingMat,
  // YieldCurveType ycType);

  // Return a vector of interpolated yield curve points from give quotes
  int GetYieldCurvePoints(
      const std::vector<YCInfo>& bondData,
      const int
          yieldDate,  // Date the curve represents. format:yyyymmdd, ie:20130507
      std::vector<double>
          samplingMat,  // Sampling vector which contains remaining maturities
      YieldCurveType ycType,  // Curve type
      std::vector<YieldPoints>&
          samplingMatYields  // Output: Yields vector corresponding to the
                             // sampling maturities
  );

  // Return a vector of interpolated yield curve points
  int GetYieldCurvePoints(
      const std::vector<YCInfo>& bondData,
      const int yieldDate,    // Date the curve represents. format:yyyymmdd
      int countSamplingPts,   // Number of sampling points
      YieldCurveType ycType,  // Curve type
      std::vector<YieldPoints>&
          samplingMatYields  // Output: Yields vector corresponding to the
                             // sampling maturities
  );

  // Return a yiled curve from give quotes
  // static InterpolatedBondYTMCurve* GetYieldCurve(const std::vector<YCInfo>&
  // bondData, const int yieldDate);

  // Return a vector of spreads between source curve and benchmark
  int GetYieldSpreads(
      const std::vector<YCInfo>& bondDataBHM,  // Benchmark yield curve data
      YieldCurveType bhmType,                  // Benchmark yield curve type
      const std::vector<YCInfo>& bondDataSrc,  // Source yield curve data
      YieldCurveType srcType,                  // Source yield curve type
      const int
          yieldDate,  // Date the curve represents. format:yyyymmdd, ie:20130507
      const int nSpreadPts,  // Number of spread points
      std::vector<YieldPoints>&
          spreads  // Output: Spreads vector between source curve and benchmark
  );

  // Return a vector of zero curve points from give quotes
  // 返回值 = 0， 成功; 返回值 != 0,
  // 失败。根据返回值调用ErrorMessage()可以找到相应的错误消息
  int GetZeroCurvePoints(
      const std::vector<YCInfo>& bondData,
      const int yieldDate,  // Input: Date the curve represents.
                            // format:yyyymmdd, ie:20130507
      int count,            // Input: Number of sampling points
      std::vector<YieldPoints>& curvePoints,  // Output: Yields vector
      YieldCurveType ycType = GOV_BOND        // Input: Curve type
  );

  // Return a yield curve pointer per given bond data and yield curve type
  // The caller needs to delete the pointer!
  BondYieldCurve* GetZeroCurve(
      const std::vector<YCInfo>& bondData,
      const int yieldDate,              // Input: Date the curve represents.
                                        // format:yyyymmdd, ie:20130507
      YieldCurveType ycType = GOV_BOND  // Input: Curve type
  );
};
